import { Toast  } from "vant";
import cTitle from "components/title";

export default {
  data() {
    return {
        date: '', //日期
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2085, 10, 1),
      currentDate: new Date(),
      searchDate: 0,
      pickerShow: false,
    list:{}
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log(localStorage.getItem("uid"),'uid')
    if(!localStorage.getItem("uid")){
        this.$router.push(this.fun.getUrl("member"));
        return
    }
    this.getData();
  },
  computed: {
   
  },
  methods: {
    openPicker() {
        this.pickerShow = true;
      },
      pickerCancel() {
        this.pickerShow = false;
      },
    submit(){
        this.getData();
    },
    getData(){
        $http.get("ZhengChengYc.commisionCount", {
            uid: localStorage.getItem("uid"),
            date: this.date
          }, "加载中").then((res) => {
            if (res.result == 1) {
              console.log(res,'commisionCount')
              this.searchDate = res.data.today;
              this.list = res.data;
            }
          });
    },
    pickerConfirm(e) {
        console.log(e, '确定')
        const dateString = e;
  
        // 将字符串转换为Date对象
        const date = new Date(dateString);
  
        // 提取年、‌月、‌日
        const year = date.getFullYear();
        const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1; // 月份是从0开始的，‌所以需要+1
        const day = date.getDate();
  
        // 拼接成年月日格式
        const formattedDate = `${year}-${month}-${day}`;
        console.log(formattedDate, 'formattedDate')
        this.date = formattedDate;
        this.pickerShow = false;
        this.getData();
      }
    
  },
};